
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/26/2013 15:13:02
-- Generated from EDMX file: C:\Cours_Insta\Projets à soutenir\Projet C#- Pour Elles\Code\FuturMaman.PourElles\FuturMaman.PourElles\ModelPourEllesBD.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [PourEllesBD];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_FemmeEnceinteMedical]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PersonneSet_FemmeEnceinte] DROP CONSTRAINT [FK_FemmeEnceinteMedical];
GO
IF OBJECT_ID(N'[dbo].[FK_GrossesseFemmeEnceinte]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[GrossesseSet] DROP CONSTRAINT [FK_GrossesseFemmeEnceinte];
GO
IF OBJECT_ID(N'[dbo].[FK_FemmeEnceinte_inherits_Personne]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PersonneSet_FemmeEnceinte] DROP CONSTRAINT [FK_FemmeEnceinte_inherits_Personne];
GO
IF OBJECT_ID(N'[dbo].[FK_Interlocuteur_inherits_Personne]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PersonneSet_Interlocuteur] DROP CONSTRAINT [FK_Interlocuteur_inherits_Personne];
GO
IF OBJECT_ID(N'[dbo].[FK_Medecin_inherits_Interlocuteur]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PersonneSet_Medecin] DROP CONSTRAINT [FK_Medecin_inherits_Interlocuteur];
GO
IF OBJECT_ID(N'[dbo].[FK_Psychologue_inherits_Interlocuteur]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[PersonneSet_Psychologue] DROP CONSTRAINT [FK_Psychologue_inherits_Interlocuteur];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[PersonneSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PersonneSet];
GO
IF OBJECT_ID(N'[dbo].[MedicalSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MedicalSet];
GO
IF OBJECT_ID(N'[dbo].[GrossesseSet]', 'U') IS NOT NULL
    DROP TABLE [dbo].[GrossesseSet];
GO
IF OBJECT_ID(N'[dbo].[PersonneSet_FemmeEnceinte]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PersonneSet_FemmeEnceinte];
GO
IF OBJECT_ID(N'[dbo].[PersonneSet_Interlocuteur]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PersonneSet_Interlocuteur];
GO
IF OBJECT_ID(N'[dbo].[PersonneSet_Medecin]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PersonneSet_Medecin];
GO
IF OBJECT_ID(N'[dbo].[PersonneSet_Psychologue]', 'U') IS NOT NULL
    DROP TABLE [dbo].[PersonneSet_Psychologue];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'PersonneSet'
CREATE TABLE [dbo].[PersonneSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nom] nvarchar(max)  NOT NULL,
    [Prenom] nvarchar(max)  NOT NULL,
    [Email] nvarchar(max)  NOT NULL,
    [Pwd] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'MedicalSet'
CREATE TABLE [dbo].[MedicalSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [GpeSanguin] nvarchar(max)  NOT NULL,
    [AntMedicaux] nvarchar(max)  NOT NULL,
    [AntFamiliaux] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'GrossesseSet'
CREATE TABLE [dbo].[GrossesseSet] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [IsToxoplasmose] bit  NOT NULL,
    [DateEcho] datetime  NOT NULL,
    [DatePriseSg] datetime  NOT NULL,
    [DateDebutSuivi] datetime  NOT NULL,
    [DateTerme] datetime  NOT NULL,
    [IsFirstGrossesse] bit  NOT NULL,
    [FemmeEnceinte_Id] int  NOT NULL
);
GO

-- Creating table 'PersonneSet_FemmeEnceinte'
CREATE TABLE [dbo].[PersonneSet_FemmeEnceinte] (
    [IdFemEnc] int IDENTITY(1,1) NOT NULL,
    [AnneeNaissance] int  NOT NULL,
    [LieuNaissance] nvarchar(max)  NOT NULL,
    [Adresse] nvarchar(max)  NOT NULL,
    [Telelphone] nvarchar(max)  NOT NULL,
    [Situation] nvarchar(max)  NOT NULL,
    [Id] int  NOT NULL,
    [Medical_Id] int  NOT NULL
);
GO

-- Creating table 'PersonneSet_Interlocuteur'
CREATE TABLE [dbo].[PersonneSet_Interlocuteur] (
    [IdInter] int IDENTITY(1,1) NOT NULL,
    [Specialisation] nvarchar(max)  NOT NULL,
    [AnneeExperience] int  NOT NULL,
    [LieuExcercice] nvarchar(max)  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'PersonneSet_Medecin'
CREATE TABLE [dbo].[PersonneSet_Medecin] (
    [IdMedecin] int IDENTITY(1,1) NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'PersonneSet_Psychologue'
CREATE TABLE [dbo].[PersonneSet_Psychologue] (
    [IdPsyco] int IDENTITY(1,1) NOT NULL,
    [Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'PersonneSet'
ALTER TABLE [dbo].[PersonneSet]
ADD CONSTRAINT [PK_PersonneSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'MedicalSet'
ALTER TABLE [dbo].[MedicalSet]
ADD CONSTRAINT [PK_MedicalSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'GrossesseSet'
ALTER TABLE [dbo].[GrossesseSet]
ADD CONSTRAINT [PK_GrossesseSet]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PersonneSet_FemmeEnceinte'
ALTER TABLE [dbo].[PersonneSet_FemmeEnceinte]
ADD CONSTRAINT [PK_PersonneSet_FemmeEnceinte]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PersonneSet_Interlocuteur'
ALTER TABLE [dbo].[PersonneSet_Interlocuteur]
ADD CONSTRAINT [PK_PersonneSet_Interlocuteur]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PersonneSet_Medecin'
ALTER TABLE [dbo].[PersonneSet_Medecin]
ADD CONSTRAINT [PK_PersonneSet_Medecin]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'PersonneSet_Psychologue'
ALTER TABLE [dbo].[PersonneSet_Psychologue]
ADD CONSTRAINT [PK_PersonneSet_Psychologue]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [Medical_Id] in table 'PersonneSet_FemmeEnceinte'
ALTER TABLE [dbo].[PersonneSet_FemmeEnceinte]
ADD CONSTRAINT [FK_FemmeEnceinteMedical]
    FOREIGN KEY ([Medical_Id])
    REFERENCES [dbo].[MedicalSet]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_FemmeEnceinteMedical'
CREATE INDEX [IX_FK_FemmeEnceinteMedical]
ON [dbo].[PersonneSet_FemmeEnceinte]
    ([Medical_Id]);
GO

-- Creating foreign key on [FemmeEnceinte_Id] in table 'GrossesseSet'
ALTER TABLE [dbo].[GrossesseSet]
ADD CONSTRAINT [FK_GrossesseFemmeEnceinte]
    FOREIGN KEY ([FemmeEnceinte_Id])
    REFERENCES [dbo].[PersonneSet_FemmeEnceinte]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GrossesseFemmeEnceinte'
CREATE INDEX [IX_FK_GrossesseFemmeEnceinte]
ON [dbo].[GrossesseSet]
    ([FemmeEnceinte_Id]);
GO

-- Creating foreign key on [Id] in table 'PersonneSet_FemmeEnceinte'
ALTER TABLE [dbo].[PersonneSet_FemmeEnceinte]
ADD CONSTRAINT [FK_FemmeEnceinte_inherits_Personne]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[PersonneSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'PersonneSet_Interlocuteur'
ALTER TABLE [dbo].[PersonneSet_Interlocuteur]
ADD CONSTRAINT [FK_Interlocuteur_inherits_Personne]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[PersonneSet]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'PersonneSet_Medecin'
ALTER TABLE [dbo].[PersonneSet_Medecin]
ADD CONSTRAINT [FK_Medecin_inherits_Interlocuteur]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[PersonneSet_Interlocuteur]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'PersonneSet_Psychologue'
ALTER TABLE [dbo].[PersonneSet_Psychologue]
ADD CONSTRAINT [FK_Psychologue_inherits_Interlocuteur]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[PersonneSet_Interlocuteur]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------